<?php

class Application_Form_Admin_ModPwdForm extends Zend_Form {

	public function init() {
		$this->setName('modpwd');

		$this->setMethod(Zend_Form::METHOD_POST)
		->setEnctype(Zend_Form::ENCTYPE_URLENCODED);
		$suppr = new Zend_Form_Element_Checkbox('suppr');
		$suppr->setAttrib('onclick','Disabled(\'pwd\');Disabled(\'pwd_verif\');')
		->setDecorators(array('ViewHelper','FormErrors','Label','Errors'))
		->setAttrib("class","menu-checkbox");

		$pwd = new Zend_Form_Element_Password('pwd');
		$pwd->addFilter('StripTags')
		->addFilter('StringTrim')
		->setDecorators(array('ViewHelper','FormErrors','Label','Errors'))
		->setAttrib("class", "menu-input")
		->setAttrib("autocomplete", "off")
		->setAttrib("onKeyup", "pwdOk($('#pwd').val())");

		$pwd_verif = new Zend_Form_Element_Password('pwd_verif');
		$pwd_verif->addFilter('StripTags')
		->addFilter('StringTrim')
		->setDecorators(array('ViewHelper','FormErrors','Label','Errors'))
		->setAttrib("class", "menu-input")
		->setAttrib("autocomplete", "off")
		->setAttrib("onKeyup", "verifPwdOk($('#pwd_verif').val())");

		$send = new Zend_Form_Element_Submit('send');
		$send->setAttrib('id','send_button')
		->setLabel('Enregistrer')
		->setAttrib('class','button')
		->setDecorators(array('ViewHelper','FormErrors','Errors'));

		$autocomplete = new ZendX_JQuery_Form_Element_AutoComplete('user');
		$autocomplete->setFilters(array('StripTags'))
		->setJQueryParams(array(
		'autoFill' => true,
		'source' => 'searchusers',
		'minLength' => 3,
		'delay' => 100,
		'select' => new Zend_Json_Expr('function(event,ui) { displayInfo(ui.item.value) }'),
		'search' => new Zend_Json_Expr('function(event,ui) { removeInfo() }'),
		))
		->setDecorators(array('UiWidgetElement','FormErrors','Label','Errors'))
		->setAttrib("class", "menu-input");

		$this->addElements(array($autocomplete,$suppr,$pwd,$pwd_verif,$send));
	}
}